import env from '@/lib/env';
import { ComposeContextProvider } from 'foxact/compose-context-provider';
import AmapProvider from './amap-provider';
import CosProvider from './cos-provider';
import TrpcProvider from './trpc-provider';

const providers = [
  <TrpcProvider key="query" />,
  <CosProvider key="cos" bucket={env.COS_BUCKET} region={env.COS_REGION} />,
  <AmapProvider
    key="amap"
    amapKey={env.AMAP_KEY}
    secretKey={env.AMAP_SECRET}
  />,
];

export default function ComposeProvider({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <ComposeContextProvider contexts={providers}>
      {children}
    </ComposeContextProvider>
  );
}
